package com.yxuan.springboot.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yxuan.springboot.mapper.InformationMapper;
import com.yxuan.springboot.model.Information;
import com.yxuan.springboot.service.InformationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;

/**
 * 
 * @author zchao
 *    Information业务层实现类
 * @date 2023-05-14 20:40:39
 */
@Slf4j
@Service
@Transactional
public class InformationServiceImpl extends BaseServiceImpl<Information> implements InformationService {

    @Autowired
    protected InformationMapper informationMapper;

    /**
     * @methodName queryInformationId
     * @effect: 返回表中所有数据的主键Id
     */
    @Override
    public List<String> queryInformationId() throws Exception {
        return informationMapper.queryInformationId();
    }

    /**
     * @methodName queryoperationNum
     * @effect: 查询文章操作的数据条数（点赞数，收藏数，分享数，阅读数）
     */
    @Override
    public String queryoperationNum(String information, String operation) throws Exception {
        return informationMapper.queryoperationNum(information,operation);
    }

    /**
     * @methodName pagingQueryInformation
     * @effect: 文章资讯分页查询
     */
    @Override
    public PageInfo<Information> pagingQueryInformation(Integer page, Integer limit) throws Exception {
        //page: 要获取哪一页的数据  limit: 每一页的数据条数
        PageHelper.startPage(page,limit);
        //调用方法查询对象，返回List
        List<Information> listInformation= informationMapper.pagingQueryInformation();
        //通过PageInfo类解析分页结果,listInformation的是我们获取数据的数组
        return new PageInfo<>(listInformation);
    }


}
